package cn.leyou.controller;

import cn.leyou.pojo.User;
import cn.leyou.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试用户表的相关Controller
 * @version 1.0.0
 * @Author yong.Mr
 * @data 2019-8-9
 */
@Slf4j  //打印日志的注解
@Transactional  // 将该类中的所有方法都加上事物控制
@CrossOrigin  // 解决跨域
@RestController
@RequestMapping("/provider")
public class UserController {
    /**
     * 注入UserService
     */
    @Autowired
    private UserService userService;

    @RequestMapping("/user/{id}")
    public User queryById(@PathVariable(name = "id") Integer id){
        User user = userService.queryById(id);
        System.out.println("通用mapper的查询方法----->" + user.toString());
        return user;
    }
    @RequestMapping("/test/{id}")
    public User getById(@PathVariable(name = "id") Integer id){
        User user = userService.getTbUser(id);
        System.out.println("测试数据自定的xml方法----->" + user.toString());
        return user;
    }

}
